# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     day130_pyqt5_event
   Description :
   Author :       fuml
   date：          2019/9/21
-------------------------------------------------
   Change Activity:
                   2019/9/21:In this example, we reimplement an
event handler.
 -------------------------------------------------
"""
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget,QApplication


class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setGeometry(300,300,250,150)
        self.setWindowTitle('EventHandler')
        self.show()

    def keyPressEvent(self, e):
        if e.Key() == Qt.Key_Escape:
            self.close()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())